var ImgNum = -1; //图片计数

var Ispaly = 1;

var JsonAlarm;

var ECharts;
var chartlinechart;

var result;
var GT3C = {};
GT3C.sendResult = function(string){
    result = string;
    init();
}

//var result = window.location.search;
//alert(result);

//var result = '{"IS_LOADBMI":"1","IS_LOADRPT":"1","dtime_hw":"0001/1/1 0:00:00","delay_hw":"","dtime_vi":"2017/7/18 14:55:59","delay_vi":"20秒","dtime_all1":"2017/7/18 14:56:09","delay_all1":"30秒","dtime_all2":"0001/1/1 0:00:00","delay_all2":"","dtime_file":"2017/7/18 14:55:53","delay_file":"14秒","SNAPPED_IMA":"../../../C3FtpRoot/FtpRoot_20170715/3C/CRH5G-5172/2017-07-18/20170718145539_1_CRH5G-5172_710_0_A/20170718145539_1_CRH5G-5172_710_0_A_IRV6.JPG","SNAPPED_JPG":"../../../C3FtpRoot/FtpRoot_20170715/3C/CRH5G-5172/2017-07-18/20170718145539_2_CRH5G-5172_710_0_A_M/Images_6.JPG","hw":"/FtpRoot_20170715/3C/CRH5G-5172/2017-07-18/20170718145539_1_CRH5G-5172_710_0_A/20170718145539_1_CRH5G-5172_710_0_A_IRV6.JPG","kjg":"/FtpRoot_20170715/3C/CRH5G-5172/2017-07-18/20170718145539_2_CRH5G-5172_710_0_A_M/Images_6.JPG","allimg":"/FtpRoot_20170715/3C/CRH5G-5172/2017-07-18/20170718145539_3_CRH5G-5172_710_0_A/Images_8.JPG","c3Show":"c3true","xj":"0","DEVICE_ID":"SDKZ$90020$00180$1$540$1","CROSSING_NO":"-1","SPEED":"244","WENDU":"115℃","HJWENDU":"25℃","LINE_HEIGHT":"5406","PULLING_VALUE":"-43","AREA_SECTION":"-1","STATION_NO":"","TRAIN_NO":"","LINE_NAME":"","wz":"&nbsp;沈丹客专&nbsp;南芬北－本溪&nbsp;大顶山隧道&nbsp;上行&nbsp;K74+761&nbsp;<a href=/Common/MOnePoleData/oneChockoneGAN.html?id=polenoinfo&device_id=SDKZ$90020$00180$1$540$1 data-rel=tooltip title=查看杆号详细情况  target=_blank>540支柱</a>","REP_INFO":"","wz_fz":"","DUTY_RANGE":"( 沈阳铁路局  沈阳供电段 )","PSD":"沈阳动车段","GSD":"沈阳供电段","JU":"沈阳铁路局","GDD":"沈阳供电段","JWD":"沈阳动车段","LINE":"沈丹客专","JUCODE":"SYJ$J02","CJ":"","BZ":"沈阳供电段","QZ":"南芬北－本溪","DIRECTION":"上行","LINE_CODE":"SDKZ$90020","POSITION_CODE":"SDKZ$90020$00180","BRIDGE_TUNNEL_NO":"SDKZ$90020$00180$00020","POLE_NUMBER":"540","KM":"K74+761","GIS_X":"123.751855","GIS_Y":"41.189773","GIS_X_O":"123.739478","GIS_Y_O":"41.181667","SUMMARYDIC":"疑似吊弦线夹燃弧","SUMMARYDICCODE":"AFBOWNETHCA","BOW_TYPE":"3车","DRIVER_NUMBER":"","DETAIL":"","STATUSDIC":"已确认","REPORT_DATE":"2017/7/18 14:58:17","RAISED_TIME":"2017-07-18 14:55:39","STATUS_TIME":"2017/7/18 14:58:06","LOCNO":"CRH5G-5172","VENDOR":"成都国铁电气","ALARM_ANALYSIS":"疑似吊弦线夹燃弧","PROPOSAL":"","REMARK":"","REPORT_PERSON":"潘淑荣","SEVERITY":"三级","SEVERITY_CODE":"三类","Loco_JU":"沈阳铁路局","CUST_ALARM_CODE":"CRH5G-5172_170718145539","IS_TYPICAL":"0","ID":"F03a79dffc32a463899d90062332ac74d","IR_PICS":["/FtpRoot_20170715/3C/CRH5G-5172/2017-07-18/20170718145539_1_CRH5G-5172_710_0_A/20170718145539_1_CRH5G-5172_710_0_A_IRV1.jpg","/FtpRoot_20170715/3C/CRH5G-5172/2017-07-18/20170718145539_1_CRH5G-5172_710_0_A/20170718145539_1_CRH5G-5172_710_0_A_IRV2.jpg","/FtpRoot_20170715/3C/CRH5G-5172/2017-07-18/20170718145539_1_CRH5G-5172_710_0_A/20170718145539_1_CRH5G-5172_710_0_A_IRV3.jpg","/FtpRoot_20170715/3C/CRH5G-5172/2017-07-18/20170718145539_1_CRH5G-5172_710_0_A/20170718145539_1_CRH5G-5172_710_0_A_IRV4.jpg","/FtpRoot_20170715/3C/CRH5G-5172/2017-07-18/20170718145539_1_CRH5G-5172_710_0_A/20170718145539_1_CRH5G-5172_710_0_A_IRV5.jpg","/FtpRoot_20170715/3C/CRH5G-5172/2017-07-18/20170718145539_1_CRH5G-5172_710_0_A/20170718145539_1_CRH5G-5172_710_0_A_IRV6.jpg","/FtpRoot_20170715/3C/CRH5G-5172/2017-07-18/20170718145539_1_CRH5G-5172_710_0_A/20170718145539_1_CRH5G-5172_710_0_A_IRV7.jpg","/FtpRoot_20170715/3C/CRH5G-5172/2017-07-18/20170718145539_1_CRH5G-5172_710_0_A/20170718145539_1_CRH5G-5172_710_0_A_IRV8.jpg","/FtpRoot_20170715/3C/CRH5G-5172/2017-07-18/20170718145539_1_CRH5G-5172_710_0_A/20170718145539_1_CRH5G-5172_710_0_A_IRV9.jpg","/FtpRoot_20170715/3C/CRH5G-5172/2017-07-18/20170718145539_1_CRH5G-5172_710_0_A/20170718145539_1_CRH5G-5172_710_0_A_IRV10.jpg","/FtpRoot_20170715/3C/CRH5G-5172/2017-07-18/20170718145539_1_CRH5G-5172_710_0_A/20170718145539_1_CRH5G-5172_710_0_A_IRV11.jpg"],"VI_PICS":["/FtpRoot_20170715/3C/CRH5G-5172/2017-07-18/20170718145539_2_CRH5G-5172_710_0_A_M/Images_1.jpg","/FtpRoot_20170715/3C/CRH5G-5172/2017-07-18/20170718145539_2_CRH5G-5172_710_0_A_M/Images_2.jpg","/FtpRoot_20170715/3C/CRH5G-5172/2017-07-18/20170718145539_2_CRH5G-5172_710_0_A_M/Images_3.jpg","/FtpRoot_20170715/3C/CRH5G-5172/2017-07-18/20170718145539_2_CRH5G-5172_710_0_A_M/Images_4.jpg","/FtpRoot_20170715/3C/CRH5G-5172/2017-07-18/20170718145539_2_CRH5G-5172_710_0_A_M/Images_5.jpg","/FtpRoot_20170715/3C/CRH5G-5172/2017-07-18/20170718145539_2_CRH5G-5172_710_0_A_M/Images_6.jpg","/FtpRoot_20170715/3C/CRH5G-5172/2017-07-18/20170718145539_2_CRH5G-5172_710_0_A_M/Images_7.jpg","/FtpRoot_20170715/3C/CRH5G-5172/2017-07-18/20170718145539_2_CRH5G-5172_710_0_A_M/Images_8.jpg","/FtpRoot_20170715/3C/CRH5G-5172/2017-07-18/20170718145539_2_CRH5G-5172_710_0_A_M/Images_9.jpg","/FtpRoot_20170715/3C/CRH5G-5172/2017-07-18/20170718145539_2_CRH5G-5172_710_0_A_M/Images_10.jpg"],"OA_PICS":["/FtpRoot_20170715/3C/CRH5G-5172/2017-07-18/20170718145539_3_CRH5G-5172_710_0_A/Images_1.jpg","/FtpRoot_20170715/3C/CRH5G-5172/2017-07-18/20170718145539_3_CRH5G-5172_710_0_A/Images_2.jpg","/FtpRoot_20170715/3C/CRH5G-5172/2017-07-18/20170718145539_3_CRH5G-5172_710_0_A/Images_3.jpg","/FtpRoot_20170715/3C/CRH5G-5172/2017-07-18/20170718145539_3_CRH5G-5172_710_0_A/Images_4.jpg","/FtpRoot_20170715/3C/CRH5G-5172/2017-07-18/20170718145539_3_CRH5G-5172_710_0_A/Images_5.jpg","/FtpRoot_20170715/3C/CRH5G-5172/2017-07-18/20170718145539_3_CRH5G-5172_710_0_A/Images_6.jpg","/FtpRoot_20170715/3C/CRH5G-5172/2017-07-18/20170718145539_3_CRH5G-5172_710_0_A/Images_7.jpg","/FtpRoot_20170715/3C/CRH5G-5172/2017-07-18/20170718145539_3_CRH5G-5172_710_0_A/Images_8.jpg","/FtpRoot_20170715/3C/CRH5G-5172/2017-07-18/20170718145539_3_CRH5G-5172_710_0_A/Images_9.jpg","/FtpRoot_20170715/3C/CRH5G-5172/2017-07-18/20170718145539_3_CRH5G-5172_710_0_A/Images_10.jpg","/FtpRoot_20170715/3C/CRH5G-5172/2017-07-18/20170718145539_3_CRH5G-5172_710_0_A/Images_11.jpg","/FtpRoot_20170715/3C/CRH5G-5172/2017-07-18/20170718145539_3_CRH5G-5172_710_0_A/Images_12.jpg","/FtpRoot_20170715/3C/CRH5G-5172/2017-07-18/20170718145539_3_CRH5G-5172_710_0_A/Images_13.jpg","/FtpRoot_20170715/3C/CRH5G-5172/2017-07-18/20170718145539_3_CRH5G-5172_710_0_A/Images_14.jpg"],"OB_PICS":[],"FRAME_INFO":["最高温度:28℃ 环境温度:24.9℃ 导高值:5397mm 拉出值:56mm 速度:244km/h","最高温度:43℃ 环境温度:24.9℃ 导高值:5397mm 拉出值:41mm 速度:244km/h","最高温度:74℃ 环境温度:24.9℃ 导高值:5387mm 拉出值:171mm 速度:244km/h","最高温度:28℃ 环境温度:24.9℃ 导高值:5406mm 拉出值:16mm 速度:244km/h","最高温度:27℃ 环境温度:24.9℃ 导高值:5406mm 拉出值:0mm 速度:244km/h","最高温度:115℃ 环境温度:24.9℃ 导高值:5406mm 拉出值:-43mm 速度:244km/h","最高温度:27℃ 环境温度:24.9℃ 导高值:5416mm 拉出值:-83mm 速度:244km/h","最高温度:27℃ 环境温度:24.9℃ 导高值:5416mm 拉出值:-72mm 速度:244km/h","最高温度:27℃ 环境温度:24.9℃ 导高值:5416mm 拉出值:-111mm 速度:244km/h","最高温度:27℃ 环境温度:24.9℃ 导高值:5416mm 拉出值:-126mm 速度:244km/h","最高温度:27℃ 环境温度:24.9℃ 导高值:5416mm 拉出值:-154mm 速度:244km/h"],"PLAY_IDX":[{"FLAG":0,"IR":0,"VI":3,"OA":4,"OB":0},{"FLAG":0,"IR":1,"VI":3,"OA":5,"OB":1},{"FLAG":0,"IR":2,"VI":4,"OA":5,"OB":3},{"FLAG":0,"IR":3,"VI":5,"OA":6,"OB":5},{"FLAG":0,"IR":4,"VI":4,"OA":6,"OB":4},{"FLAG":0,"IR":5,"VI":5,"OA":7,"OB":6},{"FLAG":0,"IR":6,"VI":6,"OA":7,"OB":9},{"FLAG":0,"IR":7,"VI":5,"OA":7,"OB":7},{"FLAG":0,"IR":8,"VI":6,"OA":8,"OB":9},{"FLAG":0,"IR":9,"VI":6,"OA":8,"OB":10},{"FLAG":0,"IR":10,"VI":7,"OA":9,"OB":12},{"FLAG":1,"IR":5,"VI":5,"OA":7,"OB":6}],"FRAME_INFO_LIST":[{"FRAME_NO":0,"ROUTING_NO":0,"KM_MARK":-1,"TEMP_IRV":2800,"TEMP_ENV":2490,"LINE_HEIGHT":5397,"PULLING_VALUE":56,"SPEED":244},{"FRAME_NO":1,"ROUTING_NO":0,"KM_MARK":-1,"TEMP_IRV":4300,"TEMP_ENV":2490,"LINE_HEIGHT":5397,"PULLING_VALUE":41,"SPEED":244},{"FRAME_NO":2,"ROUTING_NO":0,"KM_MARK":-1,"TEMP_IRV":7400,"TEMP_ENV":2490,"LINE_HEIGHT":5387,"PULLING_VALUE":171,"SPEED":244},{"FRAME_NO":3,"ROUTING_NO":0,"KM_MARK":-1,"TEMP_IRV":2800,"TEMP_ENV":2490,"LINE_HEIGHT":5406,"PULLING_VALUE":16,"SPEED":244},{"FRAME_NO":4,"ROUTING_NO":0,"KM_MARK":-1,"TEMP_IRV":2700,"TEMP_ENV":2490,"LINE_HEIGHT":5406,"PULLING_VALUE":0,"SPEED":244},{"FRAME_NO":5,"ROUTING_NO":0,"KM_MARK":-1,"TEMP_IRV":11500,"TEMP_ENV":2490,"LINE_HEIGHT":5406,"PULLING_VALUE":-43,"SPEED":244},{"FRAME_NO":6,"ROUTING_NO":0,"KM_MARK":-1,"TEMP_IRV":2700,"TEMP_ENV":2490,"LINE_HEIGHT":5416,"PULLING_VALUE":-83,"SPEED":244},{"FRAME_NO":7,"ROUTING_NO":0,"KM_MARK":-1,"TEMP_IRV":2700,"TEMP_ENV":2490,"LINE_HEIGHT":5416,"PULLING_VALUE":-72,"SPEED":244},{"FRAME_NO":8,"ROUTING_NO":0,"KM_MARK":-1,"TEMP_IRV":2700,"TEMP_ENV":2490,"LINE_HEIGHT":5416,"PULLING_VALUE":-111,"SPEED":244},{"FRAME_NO":9,"ROUTING_NO":0,"KM_MARK":-1,"TEMP_IRV":2700,"TEMP_ENV":2490,"LINE_HEIGHT":5416,"PULLING_VALUE":-126,"SPEED":244},{"FRAME_NO":10,"ROUTING_NO":0,"KM_MARK":-1,"TEMP_IRV":2700,"TEMP_ENV":2490,"LINE_HEIGHT":5416,"PULLING_VALUE":-154,"SPEED":244}],"ch":"CRH5G-5172","fssj":"2017/7/18 14:55:39","line":"沈丹客专","position":"南芬北－本溪","gis_x_N2":"123.75","gis_y_N2":"41.19","locname":"&nbsp;沈丹客专&nbsp;南芬北－本溪&nbsp;大顶山隧道&nbsp;上行&nbsp;K74+761&nbsp;<a href=/Common/MOnePoleData/oneChockoneGAN.html?id=polenoinfo&device_id=SDKZ$90020$00180$1$540$1 data-rel=tooltip title=查看杆号详细情况  target=_blank>540支柱</a>","localarminfo":"最高温度:115℃&nbsp;环境温度:25℃&nbsp;导高值:5406mm&nbsp;拉出值:-43mm&nbsp;速度:244km/h&nbsp;","IsCrack":"","TAX_MONITOR_STATUS":"1","TAX_SCHEDULE_STATUS":"0","TAX_POSITION":"0","ISEXPORTREPORT":"","INITIAL_CODE":"JUDGING","INITIAL_CODE_NAME":"待判定","LOCK_PERSON_ID":"","LOCK_PERSON_NAME":"","LOCK_TIME":"0001/1/1 0:00:00","ARCING_AREA":"10.67","SPARK_SHAPE":"暴燃","SPARK_ELAPSE":"52","SPARK_NUM":"1","MisShow":"false","PersonName":"超级管理员"}';
function init() {
//给id为 的元素删除点击事件
    $('#linechart').unbind("click");
    chartlinechart = document.getElementById('linechart');
    chartlinechart.style.width = body.clientWidth + 'px';
    chartlinechart.style.height = window.innerHeight + 'px';
    JsonAlarm = $.parseJSON(result);
//    JsonAlarm = $.parseJSON(Android.getJavaData());
//    alert(JsonAlarm.length());
    // 路径配置
    require.config({
        paths: {
            'echarts': 'echarts',
            'echarts/chart/line': 'echarts'
        }
    });
    require(['echarts',
        // 'echarts/chart',
        'echarts/chart/line' // 使用柱状图就加载line模块，按需加载
    ], function (ec) {
        ECharts = ec;
        if ('拉出值超限' === JsonAlarm.SUMMARYDIC || '疑似水平间距过大' === JsonAlarm.SUMMARYDIC) {
            setTimeout("createLC_LineChart()", 300);
        } else if ('导高值超限' === JsonAlarm.SUMMARYDIC || '导高差' === JsonAlarm.SUMMARYDIC) {
            setTimeout("createDG_LineChart()", 300);
        } else {
            setTimeout("createLineChart()", 300);
        }

    });

}
//
//点击事件执行的方法
function eConsole(e) {
    //红外图点击。
    //点击的序号  与红外帧号对应。
    var _index = parseInt(e.dataIndex);  //kdo
    //var _index = parseInt(e.dataIndex);  //echarts


    //计算出播放序列数组对应项。

//    for (var i = 0; i < JsonAlarm.PLAY_IDX.length; i++) {
//        if (JsonAlarm.PLAY_IDX[i].IR == _index) {
//            //找到对应的序号。
//            ImgNum = i;
//            break;
//        }
//    }
    onPointClick(_index);
}


//画温度曲线
function createLineChart() {

    // JsonAlarm = eval('(' + result + ')');


    // var myChart = require('echarts').init(chartlinechart);
    var myChart = ECharts.init(chartlinechart, theme);

    // myChart = echarts.init(document.getElementById('linechart'));

    var TempNumber = 0;

    var str_X = '[';
    for (var i = 1; i <= JsonAlarm.FRAME_INFO_LIST.length; i++) {
        if (i == 1) {
            str_X += i;
        }
        else {
            str_X += "," + i.toString();
        }
    }
    str_X += "]";

    var str_data = '[';
    for (var i = 0; i < JsonAlarm.FRAME_INFO_LIST.length; i++) {
        var aa = parseFloat(JsonAlarm.FRAME_INFO_LIST[i].TEMP_IRV / 100).toFixed(1)
        if (parseInt(aa) < -300 || aa == undefined) {
            aa = '';
        }
        if (i + 1 == JsonAlarm.FRAME_INFO_LIST.length) {
            str_data += aa + ']';
        } else {
            str_data += aa + ',';
        }
        if (parseFloat(JsonAlarm.FRAME_INFO_LIST[i].TEMP_IRV / 100) >= 80) {
            TempNumber++;
        }

    }

    //if (TempNumber > 0) {
    //    if (document.getElementById('rhTime'))
    //        document.getElementById('rhTime').innerHTML = "(燃弧时长:" + TempNumber * 20 + "毫秒)";
    //        $("#rhTime").attr("title", "(燃弧时长:" + TempNumber * 20 + "毫秒)")
    //}
    //最大导高差值
    DGchazhi(JsonAlarm);

    var _data = eval('(' + str_data + ')');

    var _XTitle = eval('(' + str_X + ')');  //申明横坐标

    var option = {
        color: ['#F17D5D', '#92D050'],
        backgroundColor: '#1b1b1b',
        tooltip: {
            trigger: 'axis',
            showDelay: 1,             // 显示延迟，添加显示延迟可以避免频繁切换，单位ms

            //
            // formatter: '{b0}: {c0}<br />{b1}: {c1}',
            formatter: '温度: {c0} ℃'
            //     formatter: function (params) {
            //         var res;
            //
            //         console.log(params[0].value);
            //         if (params[0].value == undefined || params[0].value == '-1000' || params[0].value === '' || parseInt(params[0].value) < -300) {
            //             res = '数据解析出错！';
            //         } else {
            //             res = params[0].seriesName + ':' + params[0].value + '℃';
            //
            //         }
            //         return res;
            //
            //     }
        },
        grid: {
            x: 30,
            y: 30,
            x2: 0,
            y2: 30
        },
        xAxis: [
            {

                type: 'category',
                boundaryGap: true,
                axisTick: {onGap: false},
                splitLine: {show: false},
                axisLabel: {
                    textStyle: {
                        color: '#BFBFBF'
                    }
                },
                axisLine: {
                    show: false
                },
                data: _XTitle
            }
        ],
        yAxis: [

            {
                axisLine: {show: true, lineStyle: {color: 'white', width: 0}},
                axisLabel: {
                    textStyle: {color: '#fff'},
                    formatter: function (v) {
                        if (check(v)) {
                            // return v.toFixed(1) + '\n℃'
                            return v.toFixed(1);
                        } else {
                            return v.toFixed(0);
                        }
                    }
                },
                type: 'value',
                splitLine: {
                    show: true, lineStyle: {
                        type: 'dashed'
                    }
                },
                name: '温度(℃)'
            }
        ],
        series: [
            {
                name: '温度',
                type: 'line',
                showAllSymbol: true,
                data: _data
            }
        ]

    };
    myChart.setOption(option);
    //绑定点击事件
    myChart.on('click', function (params) {
        eConsole(params)
    });


    // $("#divDropButton").css("display", "");

    // $("#linechart").show();
    // $("#lcchart").hide();
    // $("#dgchart").hide();
    // chartlinechart.style.width = window.innerWidth + 'px';
    // chartlinechart.style.height = window.innerHeight + 'px';

    myChart.resize();
};

function createLC_LineChart() {
    var myChart = ECharts.init(chartlinechart, theme);

    var str_X = '[';
    for (var i = 1; i <= JsonAlarm.FRAME_INFO_LIST.length; i++) {
        if (i == JsonAlarm.FRAME_INFO_LIST.length) {
            str_X += i + ']';
        } else {
            str_X += i + ',';
        }
    }

    var str_data = '[';
    for (var i = 0; i < JsonAlarm.FRAME_INFO_LIST.length; i++) {
        //if (JsonAlarm.FRAME_INFO_LIST[i].PULLING_VALUE.toString() == '' || JsonAlarm.FRAME_INFO_LIST[i].PULLING_VALUE == '-1000') {
        //    continue;
        //}
        //if (str_data == '[') {
        //    str_data += parseInt(JsonAlarm.FRAME_INFO_LIST[i].PULLING_VALUE);
        //}
        //else {
        //    str_data += "," + parseInt(JsonAlarm.FRAME_INFO_LIST[i].PULLING_VALUE);
        //}
        var aa = JsonAlarm.FRAME_INFO_LIST[i].PULLING_VALUE
        if (parseInt(aa) <= -1000) {
            aa = '';
        }
        if (i + 1 == JsonAlarm.FRAME_INFO_LIST.length) {
            if (aa == '') {
                str_data += aa + ']';
            } else {
                str_data += parseInt(aa) + ']';
            }
        } else {
            if (aa == '') {
                str_data += aa + ',';
            } else {
                str_data += parseInt(aa) + ',';

            }
        }


    }

    //  var _data = [Imgjson.FRAME_INFO[0].TEMP_IRV / 100, Imgjson.FRAME_INFO[1].TEMP_IRV / 100, Imgjson.FRAME_INFO[2].TEMP_IRV / 100, Imgjson.FRAME_INFO[3].TEMP_IRV / 100, Imgjson.FRAME_INFO[4].TEMP_IRV / 100, Imgjson.FRAME_INFO[5].TEMP_IRV / 100, Imgjson.FRAME_INFO[6].TEMP_IRV / 100, Imgjson.FRAME_INFO[7].TEMP_IRV / 100, Imgjson.FRAME_INFO[8].TEMP_IRV / 100, Imgjson.FRAME_INFO[9].TEMP_IRV / 100];
    var _data = eval('(' + str_data + ')');


    //var axisData = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];  //申明横坐标
    var _XTitle = eval('(' + str_X + ')');  //申明横坐标

    //最大导高差值
    DGchazhi(JsonAlarm);

    var option = {
        color: ['#F17D5D', '#92D050'],
        backgroundColor: '#1b1b1b',
        tooltip: {
            trigger: 'axis',
            showDelay: 1,             // 显示延迟，添加显示延迟可以避免频繁切换，单位ms
            formatter: '拉出值: {c0} mm'
            // formatter: function (params) {
            //     var res;
            //     if (params[0].value == undefined || params[0].value == '-1000' || params[0].value === '' || parseInt(params[0].value) < -1000) {
            //         res = '数据解析出错！';
            //     } else {
            //         res = params[0].seriesName + ':' + params[0].value + 'mm';
            //     }
            //     return res;
            //
            // }
        },
        grid: {
            x: 30,
            y: 30,
            x2: 0,
            y2: 30
        },
        xAxis: [
            {

                type: 'category',
                boundaryGap: true,
                axisTick: {onGap: false},
                splitLine: {show: false},
                axisLabel: {
                    textStyle: {
                        color: '#BFBFBF'
                    }
                },
                axisLine: {
                    show: false
                },
                data: _XTitle
            }
        ],
        yAxis: [

            {
                axisLine: {show: true, lineStyle: {color: 'white', width: 0}},
                axisLabel: {
                    textStyle: {color: '#fff'},
                    formatter: function (v) {
                        if (check(v)) {
                            return v.toFixed(1);
                        } else {
                            return v.toFixed(0);
                        }
                    }

                },
                type: 'value',
                splitLine: {
                    show: true, lineStyle: {
                        type: 'dashed'
                    }
                },
                name: ' 拉出值(mm)'
            }
        ],
        series: [
            {
                name: '拉出值',
                type: 'line',
                showAllSymbol: true,
                data: _data
            }
        ]

    };
    myChart.setOption(option);
    myChart.on('click', function (params) {
        eConsole(params)
    });

    //绑定点击事件
    // myChart.on('click', function (params) { eConsole(params) })


    // $("#linechart").hide();
    // $("#lcchart").show();
    // $("#dgchart").hide();
    myChart.resize();
}
function createDG_LineChart() {
    // var myChart = require('echarts').init(chartdgchart);
    var myChart = ECharts.init(chartlinechart, theme);

    var str_X = '[';
    for (var i = 1; i <= JsonAlarm.FRAME_INFO_LIST.length; i++) {
        //if (JsonAlarm.FRAME_INFO_LIST[i - 1].LINE_HEIGHT.toString() == '' || JsonAlarm.FRAME_INFO_LIST[i - 1].LINE_HEIGHT == '-1000' || JsonAlarm.FRAME_INFO_LIST[i-1].LINE_HEIGHT == 0) {
        //    continue;
        //}
        //if (str_X == '[') {
        //    str_X += i;
        //}
        //else {
        //    str_X += "," + i.toString();
        //}
        if (i == JsonAlarm.FRAME_INFO_LIST.length) {
            str_X += i + ']';
        } else {
            str_X += i + ',';
        }
    }


    var str_data = '[';
    for (var i = 0; i < JsonAlarm.FRAME_INFO_LIST.length; i++) {
        var aa = JsonAlarm.FRAME_INFO_LIST[i].LINE_HEIGHT
        if (aa == '' || parseInt(aa) <= 3700 || aa == 0 || parseInt(aa) > 7000) {
            aa = '';
        }


        if (i + 1 == JsonAlarm.FRAME_INFO_LIST.length) {
            if (aa == '') {
                str_data += aa + ']';
            } else {
                str_data += parseInt(aa) + ']';
            }
        } else {
            if (aa == '') {
                str_data += aa + ',';
            } else {
                str_data += parseInt(aa) + ',';

            }
        }


        //if (str_data == '[') {
        //    str_data += parseInt( aa);
        //}
        //else {
        //    str_data += "," + parseInt(aa);
        //}
    }


    var _data = eval('(' + str_data + ')');
    console.log(_data)


    var _XTitle = eval('(' + str_X + ')');  //申明横坐标

    //最大导高差值
    DGchazhi(JsonAlarm);

    var option = {
        color: ['#F17D5D', '#92D050'],
        backgroundColor: '#1b1b1b',
        tooltip: {
            trigger: 'axis',
            showDelay: 1,             // 显示延迟，添加显示延迟可以避免频繁切换，单位ms

            formatter: '导高值: {c0} mm'
            // formatter: function (params) {
            //     console.log(params)
            //     var res;
            //     if (params[0].value == undefined || params[0].value == '-1000' || params[0].value === '' || parseInt(params[0].value) < -1000) {
            //         res = '数据解析出错！';
            //     } else {
            //         res = params[0].seriesName + ':' + params[0].value + 'mm';
            //     }
            //     return res;
            //
            // }
        },
        grid: {
            x: 35,
            y: 30,
            x2: 0,
            y2: 30
        },
        xAxis: [
            {

                type: 'category',
                boundaryGap: true,
                axisTick: {onGap: false},
                splitLine: {show: false},
                axisLabel: {
                    textStyle: {
                        color: '#BFBFBF'
                    }
                },
                axisLine: {
                    show: false
                },
                data: _XTitle
            }
        ],
        yAxis: [

            {
                show: true,
                type: 'value',
                scale: true,
                //precision: 1,
                //min: 3700,
                //max: 7000,
                boundaryGap: [0.05, 0.05],
                axisLabel: {
                    textStyle: {color: '#fff'},
                    formatter: function (v) {
                        if (check(v)) {
                            return v.toFixed(1);
                        } else {
                            return v.toFixed(0);
                        }
                    }
                },
                axisLine: {show: true, lineStyle: {color: 'white', width: 0}},
                splitLine: {
                    show: true, lineStyle: {
                        type: 'dashed'
                    }
                },
                name: '导高值(mm)',
            }
        ],
        series: [
            {
                name: '导高值',
                type: 'line',
                showAllSymbol: true,
                data: _data
                //                                            ,
                //                                            markLine: {
                //                                                itemStyle: {
                //                                                    color: '#000000'
                //                                                },
                //                                                data: [
                //    											[
                //    											    { name: '标准导高设计值', value: 7000, x: 0, y: 30, itemStyle: { normal: { color: '#1e90ff'}} },
                //    											    { name: '', x: 700, y: 30, itemStyle: { normal: { color: '#1e90ff'}} }
                //    											],
                //    											[
                //    											    { name: '标准导高设计值', value: 5000, x: 0, y: 310, itemStyle: { normal: { color: '#1e90ff'}} },
                //    											    { name: '', x: 700, y: 310, itemStyle: { normal: { color: '#1e90ff'}} }
                //    											]
                //                                              ]
                //                                            }
            }
        ]

    };
    myChart.setOption(option);
    //绑定点击事件
    //myChart.on(ecConfig.EVENT.CLICK, eConsole);
    myChart.on('click', function (params) {
        eConsole(params)
    });


    //    $("#dg_chart").kendoChart({

    //        chartArea: {
    //            background: ""
    //        },
    //        seriesDefaults: {
    //            type: "line",
    //            style: "smooth"
    //        },
    //        legend: {
    //            visible: false
    //        },
    //        valueAxis: {
    //            labels: {
    //                format: "{0:N0}mm"
    //            },
    //            color: "#fff"
    //        },
    //        series: [{
    //            name: "导高值",
    //            data: _data
    //        }],
    //        categoryAxis: {
    //            categories: _XTitle,
    //            majorGridLines: {
    //                visible: false
    //            },
    //            color: "#fff",
    //            visible: true
    //        },
    //        tooltip: {
    //            visible: true,
    //            format: "{0}%",
    //            template: "#= series.name #: #= value #mm",
    //            color: "#fff"
    //        },
    //        seriesClick: Showbarinfo
    //    });

    // $("#linechart").hide();
    // $("#lcchart").hide();
    // $("#dgchart").show();
    myChart.resize();
}


function createWD_LineChart() {
    // var myChart = require('echarts').init(chartwdchart);
    var myChart = ECharts.init(chartlinechart, theme);


    var str_X = '[';
    for (var i = 1; i <= JsonAlarm.FRAME_INFO_LIST.length; i++) {
        if (i == 1) {
            str_X += i;
        }
        else {
            str_X += "," + i.toString();
        }
    }
    str_X += "]";

    var str_data = '[';
    for (var i = 0; i < JsonAlarm.FRAME_INFO_LIST.length; i++) {
        var aa = parseFloat(JsonAlarm.FRAME_INFO_LIST[i].TEMP_IRV / 100).toFixed(1)
        if (parseInt(aa) < -300 || aa == undefined) {
            aa = '';
        }
        if (i + 1 == JsonAlarm.FRAME_INFO_LIST.length) {
            str_data += aa + ']';
        } else {
            str_data += aa + ',';
        }


    }

    var _data = eval('(' + str_data + ')');

    var str_dataDG = '[';
    //for (var i = 0; i < JsonAlarm.FRAME_INFO_LIST.length; i++) {
    //    if (JsonAlarm.FRAME_INFO_LIST[i].LINE_HEIGHT.toString() == '' || JsonAlarm.FRAME_INFO_LIST[i].LINE_HEIGHT == '-1000' || JsonAlarm.FRAME_INFO_LIST[i].LINE_HEIGHT == 0) {
    //        str_dataDG += ","
    //        continue;
    //    }
    //    if (i < JsonAlarm.FRAME_INFO_LIST.length) {
    //        str_dataDG += parseInt(JsonAlarm.FRAME_INFO_LIST[i].LINE_HEIGHT)+',';
    //    }

    //}

    for (var i = 0; i < JsonAlarm.FRAME_INFO_LIST.length; i++) {
        var aa = JsonAlarm.FRAME_INFO_LIST[i].LINE_HEIGHT
        if (aa == '' || parseInt(aa) <= 3700 || aa == 0 || parseInt(aa) > 7000) {
            aa = '';
        }


        if (i + 1 == JsonAlarm.FRAME_INFO_LIST.length) {
            if (aa == '') {
                str_dataDG += aa + ']';
            } else {
                str_dataDG += parseInt(aa) + ']';
            }
        } else {
            if (aa == '') {
                str_dataDG += aa + ',';
            } else {
                str_dataDG += parseInt(aa) + ',';

            }
        }


        //if (str_data == '[') {
        //    str_data += parseInt( aa);
        //}
        //else {
        //    str_data += "," + parseInt(aa);
        //}
    }


    var _dataDG = eval('(' + str_dataDG + ')');


    var _XTitle = eval('(' + str_X + ')');  //申明横坐标


    // 指定图表的配置项和数据
    var option = {
        color: ['#F17D5D', '#92D050'],
        backgroundColor: '#1b1b1b',
        legend: {
            data: ['温度', '导高'],
            x: 'left',
            textStyle: {
                color: '#BFBFBF'
            }
        },
        tooltip: {
            formatter: '温度: {c0} ℃<br />导高值: {c1} mm',
            // formatter: function (params) {
            //     var res = '';
            //     console.log(params);
            //     if (params[0].value != undefined) {
            //         res = params[0].seriesName + ':' + params[0].value + '℃' + '<br/>';
            //     }
            //     if (params[1].value != undefined) {
            //         res += params[1].seriesName + ':' + params[1].value + 'mm';
            //     }
            //     return res;
            //
            // },
            trigger: 'axis',
            showDelay: 1,             // 显示延迟，添加显示延迟可以避免频繁切换，单位ms
            axisPointer: {
                animation: false
            }

        },
        grid: {
            x: 30,
            y: 65,
            x2: 37,
            y2: 30
        },
        xAxis: [
            {

                type: 'category',
                boundaryGap: true,
                axisTick: {onGap: false},
                splitLine: {show: false},
                axisLabel: {
                    textStyle: {
                        color: '#BFBFBF'
                    }
                },
                axisLine: {
                    show: false
                },
                data: _XTitle
            }
        ],
        yAxis: [

            {
                axisLine: {show: true, lineStyle: {color: 'white', width: 0}},
                axisLabel: {
                    textStyle: {color: '#fff'},
                    formatter: function (v) {
                        if (check(v)) {
                            return v.toFixed(1);
                        } else {
                            return v.toFixed(0);
                        }
                    }
                },
                type: 'value',
                splitLine: {
                    show: true, lineStyle: {
                        type: 'dashed'
                    }
                },


                name: '温度(℃)',
                //min:-40

            },
            {
                axisLine: {show: true, lineStyle: {color: 'white', width: 0}},
                axisLabel: {
                    textStyle: {color: '#fff'},
                    formatter: function (v) {
                        if (check(v)) {
                            return v.toFixed(1);
                        } else {
                            return v.toFixed(0);
                        }
                    }

                },

                type: 'value',
                splitLine: {
                    show: true, lineStyle: {
                        type: 'dashed'
                    }
                },
                name: '导高值(mm)',
                scale: true
            }
        ],
        series: [
            {
                name: '温度',
                type: 'line',
                showAllSymbol: true,
                data: _data
            },
            {

                yAxisIndex: 1,
                name: '导高',
                type: 'line',
                data: _dataDG
            }
        ]

    };

    // 使用刚指定的配置项和数据显示图表。
    myChart.setOption(option);
    myChart.on('click', function (params) {
        eConsole(params)
    });
    // $('#linechart,#lc_chart,#dg_chart,#wd_chart').css('background', 'rgb(27,27,27)');
    myChart.resize();
}


//点击跳转到某一帧上。
function Showbarinfo(e) {

    //红外图点击。

    clearInterval(set);

    //点击的序号  与红外帧号对应。
    var _index = parseInt(e.category) - 1;  //kdo
    //var _index = parseInt(e.dataIndex);  //echarts


    //计算出播放序列数组对应项。

    for (var i = 0; i < JsonAlarm.PLAY_IDX.length; i++) {
        if (JsonAlarm.PLAY_IDX[i].IR == _index) {
            //找到对应的序号。
            ImgNum = i;
            break;
        }
    }
    play();
};


//点击跳转到某一帧上。
function GoToFrame(_index) {

    clearInterval(set);

    //滑块点击。

    ImgNum = _index;
    Ispaly = 0;
    $("#note-IR").show();
    $("#note-VI").show();
    if ($("#allimg").is(":visible")) {
        $("#note-OAB").show();
    }
    ;
    $(".iconstar").attr("src", "/C3/PC/MAlarmMonitoring/ImgTmp/play.png");

    play();
};


//关闭层
function out() {
    $('#note').animate({top: '0'}, 500, function () {
        $(this).css({display: 'none', top: '-5px'});
    });
};


//计算导高差值

function DGchazhi(JsonAlarm) {
    //最大导高差值
    if (document.getElementById('dgzdcz')) {
        var dg = [];
        var DgValue;
        for (var i = 0; i < JsonAlarm.FRAME_INFO_LIST.length; i++) {
            if (JsonAlarm.FRAME_INFO_LIST[i].LINE_HEIGHT == "-1000" || parseInt(JsonAlarm.FRAME_INFO_LIST[i].LINE_HEIGHT) <= 3700 || parseInt(JsonAlarm.FRAME_INFO_LIST[i].LINE_HEIGHT) > 7000) {
                continue;
            } else {
                dg.push(JsonAlarm.FRAME_INFO_LIST[i].LINE_HEIGHT);
            }
        }
        if (dg.length == 1) {
            DgValue = 0;
        } else {
            dg.sort(function (a, b) {
                return a - b
            });
            DgValue = dg[dg.length - 1] - dg[0];
        }

        $("#dgzdcz").attr("data-original-title", "最大导高差值：" + DgValue + "mm");
        //绑定标签插件
        $('[rel="tooltip"],[data-rel="tooltip"]').tooltip({"placement": "right", delay: {show: 0, hide: 0},});
    }
};
//js判断是否为小数
function check(c) {
    var r = /^[+-]?[1-9]?[0-9]*\.[0-9]*$/;
    return r.test(c);
}
